# -*- coding:utf-8 -*-
from tornado.web import RequestHandler
import tornado.ioloop
import numpy as np  #矩阵算法库

class MainHandler(RequestHandler):
    def post(self):
        self.set_header("Access-Control-Allow-Origin", "*");#允许所有域跨域请求
        self.set_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE,PUT");# 跨域请求的类型
        self.set_header("Access-Control-Max-Age", "3600");# 跨域生命周期
        self.set_header("Access-Control-Allow-Headers", "x-requested-with");# 跨域数据响应方式
        """post"""
        print("有请求进来了！")
        result = {}
        img_data= {}
        if not img_data =={}:
            result.__setitem__("code","success")
        else:
            result.__setitem__("code","error")
        result.__setitem__("data",img_data)
        print(result)
        self.write(result)
    def get(self):
        self.write("请使用post请求！")
class IndexHandler(RequestHandler):
    def get(self):
        self.write("Hello, world")
application =  tornado.web.Application([(r"/index", IndexHandler),(r"/user/list", MainHandler)])
if __name__ == "__main__":
    application.listen(8088)
    print("——服务器启动——")
    tornado.ioloop.IOLoop.instance().start()
